Skip to content

:octocat: Simple git webhook cli tool for automation tasks, bind git webhook to action.

License

Notifications You must be signed in to change notification settings

hustcc/webhookit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webhookit

A simple cli tool to create http server for git webhook, GitHub, GitLab, GitOsc, Gogs, Coding are all supported.

LIVE DEMO | 中文说明文档

Latest Stable Version Build Status GitHub GitLab GitOsc Gogs Coding

1. Install

pip install webhookit

Python 2 / 3 are all supported. After install, you can get two commands named webhookit and webhookit_config in your system.

2. Usage

Run webhookit --help to get help content of the command. Help content below:

# webhookit --help
Usage: webhookit [OPTIONS]

Options:
  -c, --config PATH      The web hook configure file path.
  -p, --port INTEGER     The listening port of HTTP server.
  --help                 Show this message and exit.

Run webhookit_config to get the config template strings.

Run webhookit -c config.py -p 18340 to start the http server for git webhook.

3. Example

Here is an simple example to run the webhookit http server.

# 1. install webhookit
pip install webhookit

# 2. initial a webhookit config file
webhookit_config > /home/hustcc/webhook-configs/config4hustcc.py

# 3. update config4hustcc.py with your own config and save
vim config4hustcc.py

# 4. run webhookit http server
webhookit -c config4hustcc.py

Then open http://host:18340 in your browser, can see:

  1. The webhook status.
  2. The webhook url.
  3. The webhook server configures.

4. configure file

# -*- coding: utf-8 -*-
'''
Created on Mar-03-17 15:14:34
@author: hustcc/webhookit
'''

# This means:
# When get a webhook request from `repo_name` on branch `branch_name`,
# will exec SCRIPT on servers config in the array.
WEBHOOKIT_CONFIGURE = {
    # a web hook request can trigger multiple servers.
    'repo_name/branch_name': [{
        # if exec shell on local server, keep empty.
        'HOST': '',  # will exec shell on which server.
        'PORT': '',  # ssh port, default is 22.
        'USER': '',  # linux user name
        'PWD': '',  # user password or private key.

        # The webhook shell script path.
        'SCRIPT': '/home/hustcc/exec_hook_shell.sh'
    }, 
	...],
	...
}

The python var name WEBHOOKIT_CONFIGURE can not be modified.

Each webhook has it's key with format of 'repo_name/branch_name', Each webhook can trigger a group of servers, which is the value of the key.

Server can be remote and local, if local, keep HOST, PORT, USER, PWD be empty.

5. License

MIT@hustcc.

Releases

No releases published

Packages

No packages published